package com.peng.leetcode.sort;

import java.util.Arrays;

/**
 * IsAnagram
 *
 * @author: lupeng6
 * @create: 2020/12/10 16:12
 */
public class IsAnagram {

    public static void main(String[] args) {

    }

    static class Solution {
        public boolean isAnagram(String s, String t) {
            if (s.length() != t.length()) {
                return false;
            }
            char[] arr1 = s.toCharArray();
            char[] arr2 = t.toCharArray();
            Arrays.sort(arr1);
            Arrays.sort(arr2);
            for (int i = 0; i < arr1.length; i++) {
                if (arr1[i] != arr2[i]) {
                    return false;
                }
            }
            return true;
        }
    }
}
